package com.gitee.leijin.rbac.config;


import com.gitee.leijin.rbac.config.properties.UploadProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
@EnableConfigurationProperties(value = {UploadProperties.class})
public class StorageConfig implements WebMvcConfigurer {

    @Resource
    private UploadProperties uploadProperties;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String[] locations = {"classpath:/META-INF/resources/",
                "classpath:/resources/", "classpath:/static/", "classpath:/public/", "file:" + uploadProperties.getStaticDir()};
        registry.addResourceHandler("/**")
                .addResourceLocations(locations);

    }
}
